/**
 * <AiRmob-Framework; A simple augmented reality framework for android >
    Copyright (C) <2012>  <AiRmob Team>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package rendercomponents;

public class Identifier extends Parent {
	Model3D child;
	Light lightChild;
	ModelAnimation animationChild;
	ModelGroup modelGroupChild;
	Text textChild;

	float distance;

	protected boolean holdsTransparentChild = false;

	public boolean holdsLight;
	public boolean holdsModel3D;
	public boolean holdsModelAnimation;
	public boolean holdsModelGroup;
	public boolean holdsText;

	protected float[] mTotalTransformationMatrix;

	protected Identifier(Parent parent) {
		super(parent);
		this.mTotalTransformationMatrix = new float[16];
	}

	protected void setChild(Model3D model) {
		if (this.holdsModel3D || this.holdsLight || this.holdsModelAnimation
				|| this.holdsModelGroup || this.holdsText) {
			System.out.println("Identifier allready used!");
			return;
		}
		this.child = model;
		this.holdsModel3D = true;
	}

	protected void setLightChild(Light light) {
		if (this.holdsModel3D || this.holdsLight || this.holdsModelAnimation
				|| this.holdsModelGroup || this.holdsText) {
			System.out.println("Identifier allready used!");
			return;
		}
		this.lightChild = light;
		this.holdsLight = true;
	}

	protected void setAnimationChild(ModelAnimation animation) {
		if (this.holdsModel3D || this.holdsLight || this.holdsModelAnimation
				|| this.holdsModelGroup || this.holdsText) {
			System.out.println("Identifier allready used!");
			return;
		}
		this.animationChild = animation;
		this.holdsModelAnimation = true;
	}

	protected void setModelGroupChild(ModelGroup group) {
		if (this.holdsModel3D || this.holdsLight || this.holdsModelAnimation
				|| this.holdsModelGroup || this.holdsText) {
			System.out.println("Identifier allready used!");
			return;
		}
		this.modelGroupChild = group;
		this.holdsModelGroup = true;
	}

	protected void setTextChild(Text text) {
		if (this.holdsModel3D || this.holdsLight || this.holdsModelAnimation
				|| this.holdsModelGroup || this.holdsText) {
			System.out.println("Identifier allready used!");
			return;
		}
		this.textChild = text;
		this.holdsText = true;
	}

	/**
	 * 
	 * @return the appended model3D or null of none is appended.
	 */
	public Model3D getModelChild() {
		return this.child;
	}

	/**
	 * 
	 * @return the appended light or null of none is appended.
	 */
	public Light getLightChild() {
		return this.lightChild;
	}

	/**
	 * 
	 * @return the appended modelAnimation or null of none is appended.
	 */
	public ModelAnimation getAnimationChild() {
		return this.animationChild;
	}

	/**
	 * 
	 * @return the appended text or null of none is appended.
	 */
	public Text getTextChild() {
		return this.textChild;
	}

	/**
	 * 
	 * Checks which type of child is appended to this identifier and returns it
	 * consequently.
	 * 
	 * @return the appended child or null of none is appended.
	 * 
	 */
	public Object getChild() {
		if (this.holdsModel3D)
			return this.child;
		else if (this.holdsModelAnimation)
			return this.animationChild;
		else if (this.holdsLight)
			return this.lightChild;
		else if (this.holdsModelGroup)
			return this.modelGroupChild;
		else if (this.holdsText)
			return this.textChild;
		else
			return null;
	}
}
